import javax.swing.table.AbstractTableModel;

/**
 * FormTable.java - This class extends AbstractTableModel and sets up the underlying structure
 * of FormTable, and sets all the values to empty Strings.
 *   
 * @author Andrew Gifford
 */
@SuppressWarnings("serial")
public class FormTable extends AbstractTableModel{

	public final static int MAX = 100;
	public String[][] dataValues = new String[MAX][MAX];
	
	/**
	 * Accesses for the maximum column count
	 * 
	 * @return MAX column count
	 */
	public int getColumnCount(){
		return MAX;
	}
	
	/**
	 * Accesses for the maximum row count
	 * 
	 * @return MAX row count
	 */
	public int getRowCount(){
		return MAX;
	}

	/**
	 * Sets all the values in the 2D array to empty strings
	 * 
	 * @return VOID
	 */
	public void initiateValues()
	{
		for(int i = 0; i < MAX; i++)
			for(int j = 0; j < MAX; j++)
			{
				dataValues[i][j] = "";
				setValueAt("", i, j);
			}
	}
	
	/**
	 * Accesses the value at a specified row and column
	 * 
	 * @param row	Row represented as an Integer
	 * @param column	column represented as an Integer
	 * @return the object at the specified row and column
	 */
	public Object getValueAt(int row, int column) {
		return dataValues[row][column];
	}
	
	/**
	 * Accesses the value at a specified row and column
	 * 
	 * @param row	Row represented as an Integer
	 * @param column	column represented as an Integer
	 * @return the object at the specified row and column
	 */
	public boolean isCellEditable(int rowIndex, int colIndex){
		return true;
	}
	
	/**
	 * Sets the value at a specified row and column
	 * 
	 * @param row	Row represented as an Integer
	 * @param column	column represented as an Integer
	 * @return VOID
	 */
	public void setValueAt(Object obj, int row, int col){
		dataValues[row][col] = obj.toString();
		fireTableCellUpdated(row,col);
	}
}
